<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>韭菜热搜</title>
		<link href="css/text.css" rel="stylesheet" type="text/css" />
		<style type="text/css">							
			.fixedBox{
				border: 1px solid #555555;				
				white-space: nowrap;	
			}
			.fixedBox::-webkit-scrollbar {
				width: 10px;     
				height: 10px;				
			}			
		</style>
	</head>
	<body>
		<div id="towrite1" class="fixedBox"></div>	
		
		<script type="text/javascript" src="js/json2html.js"></script>
		<script type="text/javascript" src="js/jquery.min.js"></script>
		<script>
			var text = "";
			window.onload = function() {
				text = load("A股代码.txt");	
				getSource();
				changeStyle();
			}
			
			function load(name) {
				var xhr = new XMLHttpRequest(),
				okStatus = document.location.protocol === "file:" ? 0 : 200;
				xhr.open('GET', name, false);
				xhr.overrideMimeType("text/html;charset=utf-8");//默认为utf-8
				xhr.send(null);
				return xhr.status === okStatus ? xhr.responseText : null;
			}
			
			function time_range(beginTime, endTime) {
				var strb = beginTime.split(":");
				if (strb.length != 2) {
					return false;
				}

				var stre = endTime.split(":");
				if (stre.length != 2) {
					return false;
				}

				var b = new Date();
				var e = new Date();
				var n = new Date();

				b.setHours(strb[0]);
				b.setMinutes(strb[1]);
				e.setHours(stre[0]);
				e.setMinutes(stre[1]);

				if (n.getTime() - b.getTime() > 0 && n.getTime() - e.getTime() < 0) {
					getSource1();					
					console.log(true)　　　　　　
					return true;				
				} else {
					console.log(false)
				    return false;     
				}
			}　　　
   　　　
			$(function() {
				setInterval(function() {
				//time_range("9:00","15:15")
				getSource();				
				},
				60000);
			})
						
			function changeStyle() {				
				var obj = document.getElementById("towrite1");	
				obj.style.left= "0px";
				obj.style.width= "90%";
				obj.style.fontSize="12px";	
			}	
						
			Date.prototype.Format = function (fmt) {
				var o = {
				"M+": this.getMonth() + 1, //月份
				"d+": this.getDate(), //日
				"h+": this.getHours(), //小时
				"m+": this.getMinutes(), //分
				"s+": this.getSeconds(), //秒
				"q+": Math.floor((this.getMonth() + 3) / 3), //季度
				"S": this.getMilliseconds() //毫秒
				};
				if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
				for (var k in o)
				if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
				return fmt;
			};
			
			function getLocalTime(nS) {			          
			return new Date(parseInt(nS) * 1000).Format("hh:mm:ss")}						
									
			function createXmlHttp() {
				if (window.XMLHttpRequest) {
				xmlHttp = new XMLHttpRequest();
				} else {
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
				}				
			}
			
			function changeCss(obj,id){				
				var alist = document.getElementById(id).getElementsByTagName("a");					
				for(var i = 0; i < alist.length; i++){									
					if(alist[i].id != "web"){
						alist[i].style.color = "#E5E5E5"; //给所有a标签赋原色
					}
				}
				obj.style.color = "#00FFFF"; //令当前标签高亮				
			}
			
			function getSource111() {								
				var day = new Date();
				var time = day.getTime();			
				mymonth = day.getMonth()+1;
				myday = day.getDate();
				if(mymonth >= 10){mymonth = mymonth;}else{mymonth = "0" + mymonth;}
				if(myday >= 10){myday = myday;}else{myday = "0" + myday;}
				tt = day.getFullYear() + "-" + mymonth + "-" + myday;	
				
				var url = "https://app.jiuyangongshe.com/jystock-app/api/v1/action/field"; 	                			
				createXmlHttp();
				var array = {"date":tt,"pc":1}
				xmlHttp.onreadystatechange = writeSource;
				xmlHttp.open("POST", url, true);				
				xmlHttp.setRequestHeader("platform", "3");
                xmlHttp.setRequestHeader("timestamp", time);
                xmlHttp.setRequestHeader("token", "0");
				xmlHttp.setRequestHeader("Content-Type", "application/json");
				xmlHttp.withCredentials = true
				xmlHttp.send(JSON.stringify(array)) ; 
			}
			
			function getSource() {				
				var time = new Date().getTime();
				var url = "https://app.jiuyangongshe.com/jystock-app/api/v1/article/rank-board"; 	                			
				createXmlHttp();
				var array = {}
				xmlHttp.onreadystatechange = writeSource;
				xmlHttp.open("POST", url, true);				
				xmlHttp.setRequestHeader("platform", "3");
                xmlHttp.setRequestHeader("timestamp", time);
                xmlHttp.setRequestHeader("token", "0");
				xmlHttp.withCredentials = true
				xmlHttp.send(JSON.stringify(array)) ; 
			}
			
			var dms = "";
			var dmr = "";
			function writeSource() { 
				if (xmlHttp.readyState == 4) {         
					var data = xmlHttp.responseText	
					//document.write(data);
					data = data.match(/"hot_search_list":(\S*),"hot_article_list"/)[1];
					//document.write(data);
					
					text = text.replace(/ /g,'')
					//document.write(text);
					var html = "";
					var ss = data.split('},{');				
					for (i = 0; i < ss.length; i++){
						var mc = ss[i].match(/"keyword":"(\S*)"/)[1];
						mc = mc.replace("A","Ａ");
						var dm = "xxxxxx";
						if(text.indexOf(mc) > -1){
							dm = text.split("|" + mc)[0];
							dm = dm.slice(-6);
						}
						var wz = "<a href='http://www.treeid/dlghttps://www.jiuyangongshe.com/search/new?k=" + mc + "' id='web' style='color:#FF8C00'>网址</a>";
						html += "<p><a href=http://www.treeid/code_" + dm + " onclick='changeCss(this,\"towrite1\")'>" + dm + "&nbsp;&nbsp;" + mc + wz + "</a></p>"												
					}
					
					div = document.getElementById('towrite1');					
					div.innerHTML = '<h4 style="color:#FFD700">韭菜热搜</h4>' + html;
				}
			}
			
		</script>	
	</body>
</html>